package dao;

import domain.Orders;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface OrdersDao {

    @Select(" select * from orders")
    @Results(id = "id",value = {
            @Result(id = true,property = "id" ,column = "id"),
            @Result(property = "product" ,column = "productid",one = @One(select = "dao.ProductDao.findById"))
    })
    List<Orders> findAll();

    @Select("select * from orders where id=#{id}")
    @Results(value = {
            @Result(id = true,property = "id" ,column = "id"),
            @Result(property = "product" ,column = "productid",one = @One(select = "dao.ProductDao.findById")),
            @Result(property = "member", column = "memberId" ,one = @One(select = "dao.MemberDao.findById")),
            @Result(property = "travellers" ,column = "id" ,many = @Many(select = "dao.TravellerDao.findByOrderId"))
    })
    Orders findById(String id);
}
